import store from '@/store/index.js'
import { findUnReadMessage } from '@/api/message.js'

async function setUnReadMessage() {
	if(!store.state.user.token) return uni.removeTabBarBadge({index: 1})
	const res = await findUnReadMessage()
	if(res.code !== 200 || res.data == 0) {
		uni.removeTabBarBadge({
			index: 1,
		})
	}else {
		uni.setTabBarBadge({
			index: 1,
			text: `${res.data}`
		})
	}
}

export default setUnReadMessage